using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Collections;
//using Microsoft.VisualBasic;
using System.Diagnostics;
using System;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.ComponentModel.Design;
using System.Windows.Forms.Design;
using System.Drawing.Design;
using Widgetsphere.Generator.Forms;

namespace Widgetsphere.Generator.Design.Editors
{
  internal class SQLEditor : System.Drawing.Design.UITypeEditor
	{			
		#region Edit Style
		
		public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
		{
			return System.Drawing.Design.UITypeEditorEditStyle.Modal;
		}
		
		public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
		{
      System.Windows.Forms.Design.IWindowsFormsEditorService edSvc = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));

      SQLForm popupUI = new SQLForm();
      popupUI.SQL = (string)value;
      if(edSvc.ShowDialog(popupUI) == System.Windows.Forms.DialogResult.OK)
      {
        value = popupUI.SQL;
        context.OnComponentChanged();
      }
      return value;			
		}
		
		#endregion
		
	}
	
}

